package com.example.javabase.multithread.threadpools;

import javafx.concurrent.Task;
import sun.nio.ch.ThreadPool;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author He Changjie on 2021/7/11
 */
public class Main1 {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10, 25, 10L, TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(), new CustomThreadFacotry(), new ThreadPoolExecutor.AbortPolicy());

        Runnable runnable1 = () -> {
            System.out.println(Thread.currentThread().getName());
        };
        Runnable runnable2 = () -> {
            System.out.println(Thread.currentThread().getName());
        };
        Runnable runnable3 = () -> {
            System.out.println(Thread.currentThread().getName());
        };

        threadPoolExecutor.execute(runnable1);
        threadPoolExecutor.execute(runnable2);
        threadPoolExecutor.execute(runnable3);
        threadPoolExecutor.shutdown();
    }
}
